<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>营销管理系统</title>
	<link rel="stylesheet" type="text/css" href="themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="themes/icon.css">
	<link rel="stylesheet" type="text/css" href="./demo/demo.css">
	<script type="text/javascript" src="jquery.min.js"></script>
	<script type="text/javascript" src="jquery.easyui.min.js"></script>
    <script type="text/javascript" src="extend.js"></script>
</head>
<body style="text-align:center">
    <center>
        <h2>营销管理系统登录</h2>
        <p></p>
        <div style="margin:20px 0"></div>
        <div class="easyui-panel" style="width:400px;padding: 50px 50px;">
            <div style="margin-bottom:20px">
                <input class="easyui-textbox" id="uid" prompt="请输入用户名" iconWidth="28" style="width:100%;height:34px;padding:10px;">
            </div>
            <div style="margin-bottom:20px">
                <input id="pwd" class="easyui-passwordbox" prompt="请输入密码" iconWidth="28" style="width:100%;height:34px;padding:10px">
            </div>
            <div style="margin-bottom:20x">
                <input id="site" class="easyui-combobox" name="site" style="width:100%;" data-options="
					valueField: 'AutoId',
					textField: 'Name',
					">
            </div>
            <div style="text-align:center;padding:20px 0">
                <a href="javascript:void(0)" iconCls="icon-ok" class="easyui-linkbutton" onclick="getValid('./normal/index.html')" style="width:100px">登录应用</a>
                <a href="javascript:void(0)" iconCls="icon-more" class="easyui-linkbutton" onclick="getValid('./system/index.html')" style="width:100px">登录管理</a>
            </div>
        </div>

    </center>
	<div id="viewer"></div>

	<script type="text/javascript">
		$(document).ready(function(){
			loadSite();
		});
		$('#pass').passwordbox({
			inputEvents: $.extend({}, $.fn.passwordbox.defaults.inputEvents, {
				keypress: function(e){
					var char = String.fromCharCode(e.which);
					$('#viewer').html(char).fadeIn(200, function(){
						$(this).fadeOut();
					});
				}
			})
		})
        function getValid(redirtUrl){
            var usr = $("#uid").textbox("getValue");
            var pwd = $("#pwd").textbox("getValue");
            var site = $('#site').combobox('getValue');
            if(usr==""||pwd==""){
                $.messager.alert("提示","请输入账号密码及登录组织","warning");
                return;
            }
            if(site==""){
                site = 0;
            }
            showMask();
            $.get("../api/user/login?user="+usr+"&password="+pwd+"&site="+site,function(response){
                if(response.Result==0){
                    window.location = redirtUrl;
                }else{
                    $.messager.alert("错误",response.Message,"error");
                }
            },"json")
            .error(function(){
                $.messager.alert("错误","系统内部错误","error");
            })
            .complete(function() { 
                hideMask();
            });
        }
        function loadSite(){
            showMask();
            $.get("../api/site/list",function(response){
                if(response.Result==0){
                    var json = JSON.parse(response.Data);
                    $('#site').combobox('loadData', json);
                }
            },"json")
            .complete(function(){hideMask();});
        }
	</script>
	<style>
		#viewer{
			position: relative;
			padding: 0 60px;
			top: -70px;
			font-size: 54px;
			line-height: 60px;
		}
	</style>
</body>
</html>